<template>
  <el-dialog :visible.sync="visible" v-dialogDrag :title="title" :close-on-click-modal="false" class="tl-dialog" width="1200px" @open="open" @close="close">
    <el-form class="tl-form" ref="form" :model="model" :rules="rules" label-width="150px" :disabled="disableEditSubmit">
      <el-row>
        <el-col :span="12">
          <el-form-item label="名称" prop="name" :rules="rules.validateRequire">
            <el-input v-model="model.name"></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="角色编码" prop="code" :rules="rules.validateRequire">
            <el-input v-model="model.code"></el-input>
          </el-form-item>
        </el-col>
      </el-row>
      <el-row>
        <el-col :span="12">
          <el-form-item label="所属流程" prop="dispflowid">
            <el-input v-model="model.dispflowid" disabled></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="角色类型" prop="roletype" :rules="rules.validateRequire">
            <el-select v-model="model.roletype" filterable clearable>
              <el-option v-for="item in codeModel.roletypeList" :key="item.code" :label="item.name" :value="item.code" />
            </el-select>
          </el-form-item>
        </el-col>
      </el-row>
      <el-row v-if="model.roletype === '1'">
        <el-col :span="12">
          <el-form-item label="关联表名" prop="relationtable" :rules="rules.validateRequire">
            <el-input v-model="model.relationtable"></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="匹配编码" prop="relationkey" :rules="rules.validateRequire">
            <el-input v-model="model.relationkey"></el-input>
          </el-form-item>
        </el-col>
      </el-row>
      <el-row v-if="model.roletype === '1'">
        <el-col :span="12">
          <el-form-item label="匹配人员类型" prop="relationtype">
            <el-input v-model="model.relationtype"></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="资源编码" prop="souceidcolumn">
            <el-input v-model="model.souceidcolumn"></el-input>
          </el-form-item>
        </el-col>
      </el-row>
      <el-row>
        <el-col :span="24">
          <el-form-item label="备注" prop="description">
            <el-input v-model="model.description" type="textarea" :rows="4"></el-input>
          </el-form-item>
        </el-col>
      </el-row>
      <el-row>
        <el-col :span="12">
          <el-form-item label="排序码" prop="sortcode">
            <el-input-number v-model="model.sortcode" controls-position="right" :step="1" :min="0" style="width:100%"></el-input-number>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="有效" prop="enabled">
            <el-radio-group v-model="model.enabled">
              <el-radio :label="parseInt(item.code)" v-for="item in codeModel.enabledList" :key="item.code">{{ item.name }}</el-radio>
            </el-radio-group>
          </el-form-item>
        </el-col>
      </el-row>
    </el-form>
    <div slot="footer" class="dialog-footer">
      <el-button :type="disableEditSubmit === false ? 'text' : 'primary'" @click="doCancelEdit">取消</el-button>
      <el-button type="primary" @click="doSubmitEdit" :loading="saveLoading" v-if="disableEditSubmit === false">确认</el-button>
    </div>
  </el-dialog>
</template>

<script>
/** mixins */
import { mixin_edit } from '@tapui/mixins/mixin_edit'
/** 子组件 */
/** 工具类 */
import { putAction, getAction, postAction, deleteAction } from '@tapui/utils/http'
/** VUE配置 */
export default {
  mixins: [mixin_edit],
  components: {},
  data() {
    return {
      moduleTitle: '流程角色',
      urlPrefix: '/base/flowRole/',
      url: {
        // 额外的url
        queryApprovalFlowTree: '/cbo/approvalFlow/queryTreeList',
        queryApprovalFlowList: '/cbo/approvalFlow/list'
      }
    }
  },
  methods: {
    loaded() {
      // 页面加载完毕执行
      if (this.model.hasOwnProperty('roletype')) {
        this.$set(this.model, 'roletype', this.model.roletype.toString())
      }
    }
  }
}
</script>
